package fudan.se.project.repository.projection;

import fudan.se.project.domain.conference.post.Reply;
import fudan.se.project.repository.projection.summary.RoleSummary;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

public class ReplyProjection {

    private final Reply reply;

    private ReplyProjection(Reply reply) {
        this.reply = reply;
    }

    public long getId() {
        return reply.getId();
    }

    public RoleSummary getSender() {
        return new RoleSummary(reply.getSender());
    }

    public Date getTimeSent() {
        return reply.getTimeSent();
    }

    public String getComment() {
        return reply.getComment();
    }

    public static ReplyProjection project(Reply reply) {
        return new ReplyProjection(reply);
    }

    public static List<ReplyProjection> project(Collection<Reply> replies) {
        ArrayList<ReplyProjection> arrayList = new ArrayList<>(replies.size());
        for (Reply value : replies) {
            arrayList.add(project(value));
        }
        return arrayList;
    }
}
